import React, {useState} from 'react';
let useMy = function(){
    let [num,setNum] = useState(1);
    let [arr,setArr] = useState([]);
    return {
        num,
        setNum,
        arr,
        setArr
    }
}

function App(props) {
    // hooks函数分为：内置，自定义，第三方
    // hooks函数特点：1- 以use开头   2-只能在函数组件或自定义的hooks函数中调用
    // useState useEffect
    const {num,setNum,arr,setArr} = useMy();
    return (
        <div>
            <button onClick={()=>setNum(num+1)}>{num}</button>
            <button onClick={()=>{
                // arr.push(arr.length);
                // setArr([...arr]);

                // setArr([
                //     ...arr,
                //     arr.length
                // ])

                setArr([
                    1,
                    ...arr
                ]);
                // setNum(100);
            }}>{arr}</button>
        </div>
    );
}

export default App;